﻿using System;
using System.Collections.Generic;

namespace InteractiveFiction.Model
{
    /// <summary>
    /// Something that happens in the story. The Interpreter will process it into narration. StoryEvents are the words that the Interpreter uses to communicate with the Model.
    /// </summary>
    public class StoryEvent
    {
        Noun _subject;
        Verb _verb;
        IEnumerable<Noun> _directObjects;
        IEnumerable<Noun> _indirectObjects;


        public StoryEvent(Noun subject, Verb verb)
        {
            _subject = subject;
            _verb = verb;
        }

        public StoryEvent(Noun subject, Verb verb, IEnumerable<Noun> directObjects)
        {
            _subject = subject;
            _verb = verb;
            _directObjects = directObjects;
        }

        public StoryEvent(Noun subject, Verb verb, IEnumerable<Noun> directObjects, IEnumerable<Noun> indirectObjects)
        {
            _subject = subject;
            _verb = verb;
            _directObjects = directObjects;
            _indirectObjects = indirectObjects;
        }

        public string ToString()
        {
            return _subject.Name + " " + _verb.ToString() + ObjectsString() + ".";
        }

        string ObjectsString()
        {
            if (_directObjects == null)
                return "";

            string s = "";
            foreach (Noun o in _directObjects)
            {
                s += " " + o.Name;
            }

            return s;
        }

    }
}
